/********************************************************************************
 *      Copyright:  (C) 2022 YanlinZhou<1222>
 *                  All rights reserved.
 *
 *       Filename:  sqlite.h
 *    Description:  This head file 
 *
 *        Version:  1.0.0(04/09/2022)
 *         Author:  YanlinZhou <1222>
 *      ChangeLog:  1, Release initial version on "04/09/2022 05:34:47 PM"
 *                 
 ********************************************************************************/

#ifndef  _SQLITE_H_
#define  _SQLITE_H_

#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include "sqlite3.h"

typedef struct
{
	sqlite3			*db;
	char			*table_name;
	char			*database_name;
	char			*db_str;
} sqlite_info_t;


/***************************Funtion declaration******************************
| * Function nam: inquire_first_row
| * Funtion performance: 
| * Parameter: 
| * Returned value: int -1 or 0
| * Description: 
*****************************************************************************/
int inquire_first_row(sqlite_info_t *sqlite_info);


/***************************Funtion declaration******************************
| * Function nam: delete_db_first_record
| * Funtion performance:
| * Parameter:
| * Returned value: int -1 or 0
| * Description:
*****************************************************************************/
int delete_db_first_record(sqlite_info_t sqlite_info);


/***************************Funtion declaration******************************
| * Function nam: create_database_and_table
| * Funtion performance: Creat a database
| * Parameter: NULL
| * Returned value:A database fd
| * Description: Creat a database named temp.db and create a table name temp
*****************************************************************************/
int create_database_and_table(sqlite_info_t sqlite_info);


/***************************Funtion declaration******************************
| * Function nam: client_save_data
| * Funtion performance: Save the clien data to the databasen
| * Parameter: char *sample_data
| * Returned value:NULL
| * Description: NULL
*****************************************************************************/
int client_save_data(sqlite_info_t sqlite_info, float temperature, char *time);


/***************************Funtion declaration******************************
| * Function nam: create a database
| * Funtion performance: Creat a database
| * Parameter: NULL
| * Returned value:A database fd
| * Description: Creat a database named temp.db and create a table name temp
*****************************************************************************/
int create_database(sqlite3 **db, char *database_name);


/***************************Funtion declaration******************************
| * Function nam: create a table
| * Funtion performance: Creat a table
| * Parameter: NULL
| * Returned value:A database fd
| * Description: Creat a database named temperature.db and create a table name temp_tb
*****************************************************************************/
int create_table(sqlite_info_t sqlite_info);

#endif   /* ----- #ifndef _SQLITE_H_  ----- */

